﻿@model Eqwww.Config.DbBackupConfig

@{
    ViewData["Title"] = "数据备份配置";
    Layout = "~/Views/Shared/_ManageFormLayout.cshtml";
}


<form id="form1" class="mdui-m-t-3 mdui-m-b-3">
    <div asp-validation-summary="ModelOnly" class="mdui-textfield-error"></div>
    <div class="mdui-container">

        <div class="mdui-row">


            <div class="mdui-col-xs-12">
                <div class="mdui-subheader">备份设置</div>
            </div>
            <div class="mdui-col-xs-12 mdui-col-md-6">
                <div class="mdui-list">

                    <div class="mdui-list-item mdui-color-grey-100 mdui-ripple">
                        <i class="mdui-list-item-icon mdui-icon material-icons">backup</i>
                        <div class="mdui-list-item-content">
                            <div class="mdui-list-item-title">
                                @Html.DisplayNameFor(modelItem => Model.UseCustomBackupDatabaseName)
                            </div>
                            <div class="mdui-list-item-text">
                                是否备份自定义数据库
                            </div>
                        </div>
                        <label class="mdui-switch">
                            <input asp-for="UseCustomBackupDatabaseName" />
                            <i class="mdui-switch-icon"></i>
                        </label>
                    </div>


                </div>
            </div>

            <div class="mdui-col-xs-12 mdui-col-md-6">

                <div class="mdui-textfield mdui-textfield-floating-label">
                    <label asp-for="CustomBackupDatabaseName" class="mdui-textfield-label"></label>
                    <input asp-for="CustomBackupDatabaseName" class="mdui-textfield-input mdui-color-grey-100" />
                    <span asp-validation-for="CustomBackupDatabaseName" class="mdui-textfield-error"></span>
                </div>
            </div>

            <div class="mdui-col-xs-12">
                <div class="mdui-subheader">自动备份设置</div>
            </div>
            <div class="mdui-col-xs-12 mdui-col-md-6">
                <div class="mdui-list">

                    <div class="mdui-list-item mdui-color-grey-100 mdui-ripple">
                        <i class="mdui-list-item-icon mdui-icon material-icons">access_time</i>
                        <div class="mdui-list-item-content">
                            <div class="mdui-list-item-title">
                                @Html.DisplayNameFor(modelItem => Model.UseAutoBackup)
                            </div>
                            <div class="mdui-list-item-text">
                                启用后将执行自动备份数据库任务
                            </div>
                        </div>
                        <label class="mdui-switch">
                            <input asp-for="UseAutoBackup" />
                            <i class="mdui-switch-icon"></i>
                        </label>
                    </div>


                </div>
            </div>

            <div class="mdui-col-xs-12 mdui-col-md-6">

                <div class="mdui-textfield mdui-textfield-floating-label">
                    <label asp-for="Cron" class="mdui-textfield-label"></label>
                    <input asp-for="Cron" class="mdui-textfield-input mdui-color-grey-100" />
                    <span asp-validation-for="Cron" class="mdui-textfield-error"></span>
                </div>
            </div>


        </div>

    </div>
</form>


@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}

    <script>


        $(function () {
            
        });

        function submitForm() {
            if (!$("#form1").valid()) {
                return false;
            }

            if ($('#UseCustomBackupDatabaseName').is(':checked')) {
                if ($('#CustomBackupDatabaseName').val() == '') {
                    top.$.errorLayer('自定义备份数据库时，数据库名称不能为空！');
                    return false;
                }
            }

            var postData = $('#form1').formSerialize();
            $.submitForm({
                url: "/SystemSecurity/DbBackup/ConfigSubmit",
                param: postData,
                success: function () {
                    //top.window.location.reload();
                    $.currentWindow().location.reload();
                }
            });

        };
    </script>
}

